package com.asg.guesswhat;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

public class Config {
	Properties configFile;

	public Config(String configFilePath) {
		//System.out.println(configFilePath);
		configFile = new java.util.Properties();
		try {
			//configFile.load(this.getClass().getClassLoader().getResourceAsStream(configFilePath));
			configFile.load(new FileInputStream(configFilePath));
		} catch (Exception eta) {
			eta.printStackTrace();
		}
	}
	
	public String getProperty(String key) {
		String value = this.configFile.getProperty(key);
		return value;
	}
	
	public void setProperty(String key, String value, String configFilePath){
		this.configFile.setProperty(key,value);
		try {
			this.configFile.store(new FileOutputStream(configFilePath), null);
			//this.configFile.store(this.getClass().getClassLoader().getResourceAsStream(configFilePath),null);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}